package com.hotel.services.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hotel.daos.VipMapper;
import com.hotel.entitys.Staff;
import com.hotel.entitys.Vip;
import com.hotel.services.VipService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class VipServiceImpl implements VipService {
    @Autowired
    private VipMapper vipMapper;

    @Override
    public PageInfo<Vip> getAllVip(Integer currentPage, Integer pageSize, String key) {
        PageHelper.startPage(currentPage,pageSize);
        List<Vip> list   =   vipMapper.selectAllvip(key);
        PageInfo<Vip> pageInfo = new PageInfo<Vip>(list);
        return pageInfo;
    }



    @Override
    public Vip getVipByNameAndIdc(String Vip_telephone, String Vip_idcard) {

        return vipMapper.login(Vip_telephone, Vip_idcard);
    }

    @Override
    public int addVip(Vip vip) {
        return vipMapper.insertVip(vip);
    }

    @Override
    public Vip getVipById(Integer vip_id) {
        return vipMapper.selectVipById(vip_id);
    }

    @Override
    public int changeVip(Vip vip) {
        return vipMapper.updateVip(vip);
    }

    @Override
    public int deleteOneVip(Integer vip_id) {
        return vipMapper.deleteVipById(vip_id);
    }

    @Override
    public int deleteMultiVip(Object[] ids) {
        return vipMapper.deleteVipByIds(ids);
    }

    @Override
    public Vip getVip(String telephone) {
        return vipMapper.selVip(telephone);
    }
}
